//
//  ParticlesViewController.m
//  Particles
//
//  Created by Sidney Just on 13.09.09.
//  Copyright __MyCompanyName__ 2009. All rights reserved.
//

#import "ParticlesViewController.h"
#import "VDead.h"

@implementation ParticlesViewController
@synthesize voidDevice;

- (void)viewDidLoad {
	[super viewDidLoad];
	
	/* Get the content managers */
	panMan = voidDevice->panManager;
	texMan = voidDevice->texManager;
	
	voidDevice.FPSLabelDisplayMode = kDisplayDownRight; // Display the FPS label
	
	[voidDevice startAnimation];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
	NSSet *allTouches = [event allTouches];
	UITouch * touch = [[allTouches allObjects] objectAtIndex:0];
	
	CGPoint firstTouchPos = [touch locationInView:[self view]]; // Get the touch position
	
	VD_ParticleEmitter *tempEmitter = [panMan createParticleEmitter]; // Create a new emitter
	[tempEmitter setTexture:[texMan loadATexture:@"Particle.png"]];
	tempEmitter.pos_x = firstTouchPos.x;
	tempEmitter.pos_y = firstTouchPos.y;
	
	/* Play with these values */
	tempEmitter.layer = 1;
	tempEmitter.maxParticles = 2500;
	
	tempEmitter.lifespan = 20;
	tempEmitter.globalLifespan = 5; // If the globalLifespan is > 0, we don't have to care about releasing the emitter!
	
	tempEmitter.gain_X = 0;
	tempEmitter.gain_Y = -120;
	
	tempEmitter.randomX = 10;
	tempEmitter.randomY = 10;
	
	tempEmitter.gravityX = 0;
	tempEmitter.gravityY = 0;
	
	tempEmitter.gainSize_x = 0;
	tempEmitter.gainSize_y = 0;
	
	tempEmitter.bright = NO;
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
